﻿@model InstallModel

@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <title>@ILS.GetResource("Title")</title>
    <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
    <link rel="shortcut icon" href="/icons/icons_0/favicon.ico">
    @if (ILS.GetCurrentLanguage().IsRightToLeft)
    {
        <link href="@Url.Content("~/lib/bootstrap/css/bootstrap.rtl.css")" type="text/css" rel="stylesheet" />
        <link href="@Url.Content("~/lib/adminLTE/css/AdminLTE.rtl.css")" type="text/css" rel="stylesheet" />
        <link href="@Url.Content("~/css/install/styles.rtl.css")" type="text/css" rel="stylesheet" />
    }
    else
    {
        <link href="@Url.Content("~/lib/bootstrap/css/bootstrap.min.css")" type="text/css" rel="stylesheet" />
        <link href="@Url.Content("~/lib/adminLTE/css/AdminLTE.min.css")" type="text/css" rel="stylesheet" />
        <link href="@Url.Content("~/css/install/styles.css")" type="text/css" rel="stylesheet" />
    }
    <script src="@Url.Content("~/lib/jquery/jquery-3.4.1.min.js")"></script>
    <script src="@Url.Content("~/lib/jquery-validate/jquery.validate-v1.19.1/jquery.validate.min.js")"></script>
    <script src="@Url.Content("~/lib/jquery-validate/jquery.validate.unobtrusive-v3.2.11/jquery.validate.unobtrusive.min.js")"></script>
    <script src="@Url.Content("~/js/public.common.js")"></script>
</head>
<body class="skin-blue">
    <div class="wrapper">
        <div class="content-header clearfix">
            <div class="row">
                <div class="col-xs-offset-9 col-xs-3">
                    <select name="language" id="language" class="language-selector form-control" onchange="window.location.href=this.value;" asp-items="Model.AvailableLanguages"></select>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-12">
                    <div class="logo-wrapper">
                        <div class="logo"></div>
                    </div>
                </div>
            </div>
        </div>
        <form asp-action="Index" asp-controller="Install" id="installation-form" method="post">
            <div class="content">
                <div asp-validation-summary="All" class="message-error"></div>

                @*<p>@ILS.GetResource("Tooltip1")</p>*@
                <p>@ILS.GetResource("Tooltip2")</p>
                <p>@ILS.GetResource("Documentation1") <a href="http://docs.nopcommerce.com/dashboard.action?utm_source=installation-page&utm_medium=footer&utm_campaign=installation-page" target="_blank">@ILS.GetResource("Documentation2")</a>.</p>

                <script>
                    function showThrobber(message) {
                        $('.throbber-header').html(message);
                        window.setTimeout(function () {
                            $(".throbber").show();
                        }, 1000);
                    }

                    $(document).ready(function () {
                        $('#installation-form').submit(function () {
                            if ($('#installation-form').valid()) {
                                $("html, body").animate({ scrollTop: 0 }, 400);
                                showThrobber('@Html.Raw(JavaScriptEncoder.Default.Encode(ILS.GetResource("Installing")))');
                                $('input[type=submit]', this).attr('disabled', 'disabled');
                            }
                        });
                    });

                    $(document).ready(function () {
                        $('#restart-form').submit(function () {
                            $("html, body").animate({ scrollTop: 0 }, 400);
                            showThrobber('@Html.Raw(JavaScriptEncoder.Default.Encode(ILS.GetResource("RestartProgress")))');
                            $('input[type=submit]', this).attr('disabled', 'disabled');
                        });
                    });

                    $(document).ready(function () {
                        $('#@Html.IdFor(x => x.ConnectionStringRaw)').click(toggleSqlConnectionInfo);

                        $("input:checkbox[name=UseCustomCollation]").click(toggleCollation);

                        toggleSqlConnectionInfo();
                        toggleCollation();
                    });

                    $(document).ready(function () {
                        $('#@Html.IdFor(m => m.DataProvider)').on('change', function() {
                            var integratedSecurityProviders = ['@((int)DataProviderType.SqlServer)']
                            if(!integratedSecurityProviders.includes($(this).val())) {
                                $('#@Html.IdFor(x => x.IntegratedSecurity)').prop('checked', false);
                                $('#@Html.IdFor(x => x.IntegratedSecurity)').prop('disabled', true)

                                toggleSqlAuthenticationType();
                            } else {
                                $('#@Html.IdFor(x => x.IntegratedSecurity)').prop('disabled', false)
                            }
                        });
                    });

                    function toggleSqlConnectionInfo() {
                        var connectionStringRaw = $("#@Html.IdFor(x => x.ConnectionStringRaw)").is(':checked');
                        if (connectionStringRaw) {
                            $('#sqlDatabaseInfo').hide();
                            $('#sqlDatabaseConnectionString').show();
                        } else {
                            $('#sqlDatabaseInfo').show();
                            $('#sqlDatabaseConnectionString').hide();
                        }
                    }

                    function toggleCollation() {

                        var connectionStringRaw = $("#@Html.IdFor(x => x.UseCustomCollation)").is(':checked');
                        var collationInput = $("#@Html.IdFor(x => x.Collation)")
                        if (connectionStringRaw) {
                            collationInput.show();
                        } else {
                            collationInput.hide();
                        }
                    }

                    @if (!string.IsNullOrEmpty(Model.RestartUrl))
                    {
                        <text>
                            $(document).ready(function () {
                                showThrobber('@Html.Raw(JavaScriptEncoder.Default.Encode(ILS.GetResource("RestartProgress")))');
                                $.ajax({
                                    type: "GET",
                                    url: "@Url.Action("RestartApplication", "Install")",
                                    complete: function() {
                                        window.setTimeout(function () {
                                            window.location.replace('@Model.RestartUrl');
                                        }, @NopCommonDefaults.RestartTimeout);
                                    }
                                });
                            });
                        </text>
                    }
                </script>

                <div class="form-horizontal">
                    <div class="panel margin-t-30">
                        <div class="panel-heading">
                            <div class="row">
                                <div class="col-xs-4 text-right">
                                    @ILS.GetResource("StoreInformation")
                                </div>
                            </div>
                        </div>
                        <div class="panel-body">
                            <div class="form-group">
                                <div class="col-xs-4">
                                    <label class="control-label">
                                        @ILS.GetResource("AdminEmail")
                                    </label>
                                </div>
                                <div class="col-xs-7">
                                    <input asp-for="AdminEmail" class="form-control" />
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-xs-4">
                                    <label class="control-label">
                                        @ILS.GetResource("AdminPassword")
                                    </label>
                                </div>
                                <div class="col-xs-7">
                                    <input asp-for="AdminPassword" class="form-control" />
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-xs-4">
                                    <label class="control-label">
                                        @ILS.GetResource("ConfirmPassword")
                                    </label>
                                </div>
                                <div class="col-xs-7">
                                    <input asp-for="ConfirmPassword" class="form-control" />
                                </div>
                            </div>
                            @if (!Model.DisableSampleDataOption)
                            {
                                <div class="form-group">
                                    <div class="col-xs-7 col-xs-offset-4">
                                        <div class="checkbox">
                                            <label>
                                                <input asp-for="InstallSampleData" />
                                                @ILS.GetResource("CreateSampleData")
                                            </label>
                                        </div>
                                    </div>
                                </div>
                            }
                        </div>
                    </div>

                    <div class="panel margin-t-10">
                        <div class="panel-heading">
                            <div class="row">
                                <div class="col-xs-4 text-right">
                                    @ILS.GetResource("DatabaseInformation")
                                </div>
                            </div>
                        </div>
                        <div class="panel-body">
                            <div class="form-group">
                                <div class="col-xs-4">
                                    <label class="control-label">
                                        @ILS.GetResource("Database")
                                    </label>
                                </div>
                                <div class="col-xs-7">
                                    <nop-select asp-for="DataProvider" asp-items="Model.AvailableDataProviders" />
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-xs-7 col-xs-offset-4">
                                    <div class="checkbox">
                                        <label>
                                            <nop-editor asp-for="CreateDatabaseIfNotExists" />
                                            @ILS.GetResource("CreateDatabaseIfDoesNotExist")
                                        </label>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-xs-7 col-xs-offset-4">
                                    <div class="checkbox">
                                        <label>
                                            <nop-editor asp-for="ConnectionStringRaw" />
                                            @ILS.GetResource("RawConnectionString")
                                        </label>
                                    </div>
                                </div>
                            </div>
                            <div id="sqlConnectionInfo">
                                <hr />
                                @await Html.PartialAsync("_Install.ConnectionString", Model)
                                <div class="form-group" id="sqlDatabaseConnectionString">
                                    <div class="col-xs-4">
                                        <label class="control-label">
                                            @ILS.GetResource("ConnectionString")
                                        </label>
                                    </div>
                                    <div class="col-xs-7">
                                        <input asp-for="ConnectionString" class="form-control" />
                                        <span class="hint">
                                            @ILS.GetResource("Example"):<br />
                                            Data Source=sqlServerName;Initial Catalog=dbName;Persist Security Info=True;User
                                            ID=userName;Password=password
                                            <br />
                                            Find more info <a href="http://www.connectionstrings.com/" target="_blank">here</a>
                                        </span>
                                    </div>
                                </div>
                                <div class="form-group" id="sqlConnectionInfo">
                                    <div class="col-xs-7 col-xs-offset-4">
                                        <div class="checkbox">
                                            <label>
                                                <input asp-for="UseCustomCollation" />
                                                @ILS.GetResource("CustomCollation")
                                            </label>
                                            <input asp-for="Collation" class="form-control margin-t-10" />
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group margin-t-30">
                                <div class="col-xs-12 text-center">
                                    <button type="submit" class="btn btn-md btn-install margin-l-5">@ILS.GetResource("Install")</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>

        <div class="content-footer">
            <form asp-action="RestartInstall" asp-controller="Install" id="restart-form" method="post">
                <div class="row">
                    <div class="col-xs-12 text-center">
                        <button type="submit" class="btn btn-md btn-default" title="@ILS.GetResource("RestartInstallationTooltip")">@ILS.GetResource("RestartInstallation")</button>
                    </div>
                </div>
            </form>
        </div>
        <div class="throbber">
            <div class="curtain">
            </div>
            <div class="curtain-content">
                <div>
                    <h1 class="throbber-header">Wait...</h1>
                    <p><img src="@Url.Content("~/css/install/images/install-synchronizing.gif")" alt="" /></p>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
